package com.wuye.rcgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.rcgl.domain.WyJzsz;
import com.wuye.rcgl.service.IWyJzszService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 记账收支Controller
 * 
 * @author wpc
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/rcgl/jzsz")
public class WyJzszController extends BaseController
{
    @Autowired
    private IWyJzszService wyJzszService;

    /**
     * 查询记账收支列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyJzsz wyJzsz)
    {
        startPage();
        List<WyJzsz> list = wyJzszService.selectWyJzszList(wyJzsz);
        return getDataTable(list);
    }

    /**
     * 导出记账收支列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:export')")
    @Log(title = "记账收支", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyJzsz wyJzsz)
    {
        List<WyJzsz> list = wyJzszService.selectWyJzszList(wyJzsz);
        ExcelUtil<WyJzsz> util = new ExcelUtil<WyJzsz>(WyJzsz.class);
        util.exportExcel(response, list, "记账收支数据");
    }

    /**
     * 获取记账收支详细信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:query')")
    @GetMapping(value = "/{jzszId}")
    public AjaxResult getInfo(@PathVariable("jzszId") Long jzszId)
    {
        return success(wyJzszService.selectWyJzszByJzszId(jzszId));
    }

    /**
     * 新增记账收支
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:add')")
    @Log(title = "记账收支", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyJzsz wyJzsz)
    {
        return toAjax(wyJzszService.insertWyJzsz(wyJzsz));
    }

    /**
     * 修改记账收支
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:edit')")
    @Log(title = "记账收支", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyJzsz wyJzsz)
    {
        return toAjax(wyJzszService.updateWyJzsz(wyJzsz));
    }

    /**
     * 删除记账收支
     */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:remove')")
    @Log(title = "记账收支", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jzszIds}")
    public AjaxResult remove(@PathVariable Long[] jzszIds)
    {
        return toAjax(wyJzszService.deleteWyJzszByJzszIds(jzszIds));
    }


    /**
     * 批量新增记账收支
     * */
    @PreAuthorize("@ss.hasPermi('rcgl:jzsz:add')")
    @Log(title = "记账收支", businessType = BusinessType.INSERT)
    @PostMapping("/manyadd")
    public AjaxResult manyadd(@RequestBody List<WyJzsz> wyJzszs)
    {
        wyJzszService.manyadd(wyJzszs);
        return success();
    }
}
